new Vue({
    el:'#integralMallApp',
    data:{

        IntegralMallList:[],  //积分商城信息数组
        integralNumber:0,  //积分
    },
    mounted:function () {

        //获取积分商城全部信息
        this.queryAllIntegralMall();


    },
    methods:{
        //获取积分商城全部信息
        queryAllIntegralMall:function () {
            var it = this;
            axios({
                url:'/logistics/customer/queryAllIntegralMall',
                method:'get'
            }).then(function (res) {
                it.IntegralMallList = res.data.data.data;
                it.integralNumber = res.data.data.integral;
            }).catch(function (error) {

            })

        },
        //积分兑换优惠卷
        integralExchange:function (index) {
            var it = this;
            $.ajax({
                url:'/logistics/customer/integralExchange',
                type:'post',
                data:{
                    integralNumber:it.IntegralMallList[index].integralPrice,
                    integralTypeId:3,
                    addOrSubtract:0,
                    integralMallId:it.IntegralMallList[index].integralMallId,
                    integralMallName:it.IntegralMallList[index].integralMallName,
                    money:it.IntegralMallList[index].money,
                    integralPrice:it.IntegralMallList[index].integralPrice
                },
                dataType:'json',
                success:function (res) {

                    if (res.code == 200){

                        it.integralNumber = it.integralNumber - it.IntegralMallList[index].integralPrice;

                        $.toast({
                            title: '信息提示框',
                            subtitle: '10秒后自动关闭',
                            content: '兑换成功',
                            type: 'success',
                            delay: 10000,
                            pause_on_hover: false
                        });

                    }else{

                        $.toast({
                            title: '信息提示框',
                            subtitle: '10秒后自动关闭',
                            content: '兑换失败，未知错误！',
                            type: 'error',
                            delay: 10000,
                            pause_on_hover: false
                        });

                    }

                }
            })



        }


    }

})
